<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>条件渲染</title>
    <script src="./js/babel.min.js"></script>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <style>
      #ad{
        width: 200px;
        height: 200px;
        position: absolute;
        right: 0;
        bottom: 0;
        background: #258;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明变量
      let isVip = false;
      let isLogin = true;

      //1. if...else...
      // let vnode = null;
      // if(!isLogin){
      //   vnode = <div>360P</div>;
      // }else{
      //   vnode = <div>1080P</div>;
      // }

      //2. 三元运算符
      //渲染
      // ReactDOM.render(<div>
      //     <h1>您正在观看的视频是 {isLogin ? '1080P 高清' : '360P 标清'}</h1>
      //   </div>, document.querySelector('#root'));

      //3. 逻辑运算符 &&
      ReactDOM.render(<div>
          {!isVip && <div id="ad"></div>}
          {isVip ? null : <div id="ad"></div>}
        </div>, document.querySelector('#root'));

    </script>
  </body>
</html>
